package com.briup.ptp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.briup.ptp.entity.Pig;
import com.briup.ptp.entity.extend.PigExtent;
import com.briup.ptp.mapper.PigMapper;
import com.briup.ptp.service.PigService;
import com.briup.ptp.utils.FastDFSUtils;
import com.briup.ptp.utils.QRCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author GaoB
* @description 针对表【pig】的数据库操作Service实现
* @createDate 2024-02-23 20:25:22
*/
@Service
public class PigServiceImpl extends ServiceImpl<PigMapper, Pig> implements PigService{
    @Autowired
    PigMapper mapper;

    @Override
    public List<PigExtent> queryPigInfo(String species, String name, Integer pageSize, Integer pageNum) {
        return mapper.PaginatedQueries(species, name, pageSize, pageNum);
    }
    //二维码
    @Override
    public String QRcode(Integer id) {
        Pig pig = mapper.selectById(id);
        String fileName = QRCodeUtils.QRcode(id);
        String url = FastDFSUtils.upLoad(fileName);
        pig.setQrCode(url);
        mapper.updateById(pig);
        return "二维码已生成";
    }
}




